package com.lap.auth.application.api.dto;

import java.util.ArrayList;
import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
@Schema(description = "接口树返回")
public class ApiTreeDto {

  @Schema(description = "接口id")
  private Integer id;

  @Schema(description = "接口模块")
  private String module;

  @Schema(description = "接口父编码")
  private String parentCode;

  @Schema(description = "接口编码")
  private String code;

  @Schema(description = "接口名称")
  private String name;

  @Schema(description = "接口方法")
  private String method;

  @Schema(description = "接口请求地址")
  private String uri;

  @Schema(description = "接口类型")
  private Integer apiType;

  @Schema(description = "接口方法级别")
  private Integer accessLevel;

  @Schema(description = "接口访问类型")
  private Integer viewType;

  @Setter
  @Getter(AccessLevel.NONE)
  @Schema(description = "接口子集合")
  private List<ApiTreeDto> children;

  public List<ApiTreeDto> getChildren() {
    if (children == null) {
      children = new ArrayList<>();
    }
    return children;
  }
}
